package com.orange.wwwapi.controller.auth;

import com.orange.core.pojo.R;
import com.orange.wwwapi.pojo.req.user.WxBindReq;
import com.orange.wwwapi.service.wx.WxAuthService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 微信身份认证
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/auth/wx")
public class WxAuthController {

    private final WxAuthService wxAuthService;

    /**
     * 获取手机号
     */
    @GetMapping("/getPhone")
    public R<String> getPhone(@RequestParam String code) {
        return R.ok(wxAuthService.getPhone(code));
    }

    /**
     * 微信绑定
     */
    @PostMapping("/bind")
    public R<Boolean> bind(@RequestBody WxBindReq req) {
        return R.ok(wxAuthService.bindUser(req));
    }
}
